#include "aw_windows.h"
#include "aw_control.h"
#include "../menu.h"
#include "../../user.h"
#include "ctrlconvert.h" 
#include "WinConfirmEvent.h" 

static INT8U WinFlag = 0 ;

void WhichTypeConfirmSel();

INT32S WinConfirmOnShow(PHWND hwnd, INT32S lpParam)
{
	
 	unsigned char osdsettpval(unsigned char,unsigned char level);
    switch(CurrentOsdSize){
    	default:
    		osdsettpval(2,0xf);
			break;
    }
	
	WhichTypeConfirmSel();

	PHWND dir_hwnd = AWFindWinCtrlByName(ConfigMessage);
	if(dir_hwnd)
		AWShowWinControl(dir_hwnd,1);
    return 0 ;
}

INT32S ConfigMessageOnKeyPress(PHWND hwnd, INT32S lpParam)
{
	INT32U *key_value = (INT32U *)lpParam ;
	extern INT8U PlayBackResume ;
	
	switch(*key_value){		
	 	case UOP_STOP:
	 	case UOP_RESUME:
	 	    if(WinFlag == CONFIRM_NOFILE)
	 	    {
                GUIHideWindow(WinConfirm) ;
                GUIShowWindow(WinFileTypeSelect) ;
	 	    }
	 	    else if(WinFlag == CONFIRM_MOVIEPLAYBACK)
	 	    {
	 		    PlayBackResume = 1 ;
	 	    }
			break;
		
		default:
			break ;
	}	
	return 0 ;	
}


INT32S WinConfirmOnHide(hwnd,lpParam)
{
	WinFlag = 0 ;
	return 0 ;
}

//////////////////////////////////////////////////////////////////////////////////////////

void MoviePlayConfirm()
{
	extern INT32U NODIR_FLAG ;
	
	PHWND dir_hwnd = AWFindWinCtrlByName(ConfigMessage);
	if(!dir_hwnd)
		return ;
		
	if(NODIR_FLAG == 0){
        dir_hwnd->draw_info[2].draw_data = (INT32U)NONSUPPORT_STR ;
		dir_hwnd->draw_info[3].draw_data = (INT32U)TIPS2_STR ;
		dir_hwnd->draw_info[4].draw_data = (INT32U)0 ;
	}
	else if(NODIR_FLAG == 2){
        dir_hwnd->draw_info[2].draw_data = (INT32U)NONSUPPORT_STR ;
		dir_hwnd->draw_info[3].draw_data = (INT32U)TIPS1_STR;
		dir_hwnd->draw_info[4].draw_data = (INT32U)TIPS2_STR;
	}
	
	return ;
}

void NoFileConfirm(void)
{

	PHWND dir_hwnd = AWFindWinCtrlByName(ConfigMessage);
	if(!dir_hwnd)
		return ;
		
	dir_hwnd->draw_info[2].draw_data = (INT32U)NO_FILE_STR ;
	dir_hwnd->draw_info[3].draw_data = (INT32U)TIPS2_STR ;
	dir_hwnd->draw_info[4].draw_data = (INT32U)0 ;
}

void ShowSearchFile(void)
{
	PHWND dir_hwnd = AWFindWinCtrlByName(ConfigMessage);
	if(!dir_hwnd)
		return ;
		
	dir_hwnd->draw_info[2].draw_data = (INT32U)LOADING_STR ;
	dir_hwnd->draw_info[3].draw_data = (INT32U)0 ;
	dir_hwnd->draw_info[4].draw_data = (INT32U)0 ;
}

void WhichTypeConfirmSel()
{
	switch(WinFlag){
		case CONFIRM_MOVIEPLAYBACK:
			MoviePlayConfirm();
			break;
        case CONFIRM_NOFILE:
            NoFileConfirm();
			break;
		case SEARCH_FILE:
            ShowSearchFile();
			break;
		default:
			break;
	}
}

void ShowWinConfirm(INT8U Win_Name_flag)
{
	WinFlag = Win_Name_flag ;
	GUIShowWindow(WinConfirm) ;
}

INT32S ConfigMessageOnOtherEvent(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    return 0 ;
}
